import java.io.*;
import java.net.Socket;

public class ClientPicture {
    public static void main(String[] args) {
        Socket socket = null;
        InputStream inputStream = null;
        OutputStream outputStream = null;
        File file = new File("D:\\githomework\\java1228\\student\\zhaofh\\HomeWork\\HomeWork0216\\Client.jpg");
        FileOutputStream fileOutputStream = null;
        try {
            socket = new Socket("127.0.0.1", 9900);
            inputStream = socket.getInputStream();
            fileOutputStream = new FileOutputStream(file);
            byte[] b = new byte[512];
            int length = inputStream.read(b);
            while (length != -1) {
                fileOutputStream.write(b, 0, length);
                length = inputStream.read(b);
            }
            socket.shutdownInput();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
